import { axiosInstance } from 'src/boot/axios'
import CommonConfig from 'src/assets/js/config'

const cutterUrl = CommonConfig.cutterUrl + '/v1'
import _ from 'lodash'
/**
 * 列举仓库
 * @returns {Promise<unknown>}
 */
export function getWarehouses () {
  const url = cutterUrl + '/warehouses'

  return axiosInstance.get(url).then(resp => {
    return Promise.resolve(resp)
  })
}

/**
 * 列举仓库所属库位
 * warehouseId 仓库id
 * @returns {Promise<unknown>}
 */
export function getStorageLocations (warehouseId) {
  let url = `${cutterUrl}/warehouses/`
  _.isNil(warehouseId) ? (url += 'storageLocations') : (url += `${warehouseId}/storageLocations`)

  return axiosInstance.get(url).then(resp => {
    return Promise.resolve(resp)
  })
}
